package com.wyw.hemerocallis.stream.wyw;

import com.alibaba.fastjson.JSON;
import com.wyw.hemerocallis.vo.WywMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Payload;

/**
 * 使用自定义的输入信道实现消息的接收
 *
 * @author Mr Wu    yewen.wu.china@gmail.com
 * <p>
 * Update History:
 * Author        Time            Content
 */
@Slf4j
@EnableBinding(WywSink.class)
public class WywReceiveService {

    /**
     * 使用自定义的输入信道接收消息
     * @param payload
     */
    @StreamListener(WywSink.INPUT)
    public void receiveMessage(@Payload Object payload) {
        log.info("in WywReceiveService consumer message start");
        WywMessage message = JSON.parseObject(payload.toString(), WywMessage.class);
        log.info("in WywReceiveService consumer message success: [{}]",
                JSON.toJSONString(message));


    }
}
